
'''作业1：打印斐波那契数列'''
#方法1
def fibonacci_print1(n):
    list=[1,1]
    while list[-2]+list[-1]<n:
        x=list[-2]+list[-1]
        list.append(x)
    print(list)

#方法2
def fibonacci_print2(n):
    x = 1
    y = 1
    list = [x, y]
    for i in range(n):
        num = x + y
        if num < n:
            list.append(num)
            x,y = y,num
        elif num > n:
            break
    print(list)

fibonacci_print1(100)
fibonacci_print2(100)



'''作业2： 激活码'''
import random as rd
'''
L:激活码长度
N:激活码数量
'''
def ActivationCode(L,N):
    str_list = []
    code_list = []
    for i in range(65, 91): str_list.append(chr(i))
    for i in range(97, 123): str_list.append(chr(i))
    for i in range(0, 10): str_list.append(str(i))
    for x in range(N):
        code = ''.join(rd.sample(str_list, L))
        if code not in code_list:
            code_list.append(code)
    code_num=len(code_list)
    return code_list,code_num


code_list,code_num=ActivationCode(10,200)
print(code_list)
print('激活码数量：%d' %code_num)